<div id="list-user">
    <div class="search-user">
        <div class="message"></div>
        <form>
            <fieldset>
                <legend>Tìm kiếm</legend>
                <label for="keyword">Nhập email hoặc họ tên cần tìm</label>
                <input name="keyword" class="keyword" type="text"/>
                <input name="search" class="search" type="button" value="Tìm kiếm"/>
            </fieldset>
        </form>
    </div>
    <div class="show-all">
        <input type="button" value="Hiển thị tất cả"/>
    </div>
    
    <!-- show user here -->
    <div class="list">
    </div>
    
    <div class="add-new">
        <a href="<?php echo $this->baseUrl('admin/user/add')?>" title="Thêm mới">Thêm mới</a>
    </div>
</div>
<div id="result"></div>
<script>
$(document).ready(function(){
	var link = "<?php echo $this->baseUrl('admin/user/list')?>";
	$.ajax({
	    url: link,
	    success: function(data){
		    $("#list-user .list").html(data);
		    },
		});
});

//search user
$(function(){
	$("#list-user .search-user input.search").click(function(){
		var link = "<?php echo $this->baseUrl('admin/user/list')?>";
		var rdata = {"keyword": $("#list-user .search-user .keyword").val()};
		
		$.ajax({
			url: link,
			data: rdata,
			success: function(rdata){
				$("#list-user .list").html(rdata);
				}
			});
		});
});

//show all user
$(function(){
	$("#list-user .show-all input").click(function(){
		var link = "<?php echo $this->baseUrl('admin/user/list')?>";
		$.ajax({
		    url: link,
		    success: function(data){
			    $("#list-user .list").html(data);
			    },
			});
	});
});
</script>

